//loading开始-----------------------------------------------------------------------------------------------
function loading(json) {
	var index = 0;
	var imgs = [];
	for (var i = 0; i < json.arr.length; i++) {
		var imgobj = new Image();
		imgobj.src = json.arr[i];
		imgobj.onload = function() {
			index++;
			var per = parseInt((index / json.arr.length) * 100);
			if (json.span) {
				json.span.innerHTML = per + '%';
			}
			if (json.CloadW) {
				json.CloadW.style.width = per + '%';
			}

			imgs.push(this);
			if (index == json.arr.length) {
				json.succFn && json.succFn();
			}

		}
	}
}
var span = document.getElementById('lspan');
var arr = ['./imgs/4.png','./imgs/5.png','./imgs/6.png','./imgs/7.png','./imgs/8.png','./imgs/9.png','./imgs/10.png',
'./imgs/bg.jpg','./imgs/bg-h.jpg','./imgs/fxbg.jpg','./imgs/ar.png','./imgs/zj.png',
'./imgs/bg1.png','./imgs/bg2.png','./imgs/bg3.png','./imgs/bg4.png',
'./imgs/bg5.png','./imgs/bg6.png','./imgs/bg7.png','./imgs/bg8.png','./imgs/bg10.png'];

var arr2=['./imgs/1.png','./imgs/2.jpg','./imgs/3.png'];
var aud1=document.getElementById('aud1');
var aud2=document.getElementById('aud2');
loading({
	arr: arr2,
	succFn: function() {
		$('.loadgroup').css({opacity:1});
		setTimeout(function(){
			loading({
				arr: arr,
				span: span,
				succFn: function() {
					setTimeout(function(){
						aud1.play();
						$('.loadgroup').animate({'opacity':0},function(){$('.loadgroup').css({'display':'none'});});
						$('.group1').animate({opacity:1});	
					},2000)
					
				}
			})
		},1000)	
	}
})


//loading结束-----------------------------------------------------------------------------------------------





$(function() {
	var winW = $(window).width();
	var winH = $(window).height();
	if(winW>=640){
		winW=640;
	}
	$('.flip10,.flip9,.flip8,.flip7,.flip6,.flip5,.flip4,.flip3,.flip2,.flip1').css({height:winH,width:winW});
	
	
	var fnum=1;
	var bol=true;	
	touch.on('.g1p1','swipeleft',function(){		
		if(bol){
			if(fnum>=10){
				fnum=10;
			}
			if(fnum<=1){
				fnum=1;
			}
			
			switch(fnum){
				case 1:$('.f1').addClass('f1a');$('.zj1').addClass('zj1a');aud2.play();
				fnum++;break;
				case 2:$('.f2').addClass('f2a');$('.zj2').addClass('zj2a');aud2.play();
				fnum++;break;
				case 3:$('.f3').addClass('f3a');$('.zj3').addClass('zj3a');aud2.play();
				fnum++;break;
				case 4:$('.f4').addClass('f4a');$('.zj4').addClass('zj4a');aud2.play();
				fnum++;break;
				case 5:$('.f5').addClass('f5a');$('.zj5').addClass('zj5a');aud2.play();
				fnum++;break;
				case 6:$('.f6').addClass('f6a');$('.zj6').addClass('zj6a');aud2.play();
				fnum++;break;
				case 7:$('.f10').addClass('f10a');$('.zj10').addClass('zj10a');aud2.play();
				fnum++;break;
				case 8:$('.f7').addClass('f7a');$('.zj7').addClass('zj7a');aud2.play();
				fnum++;break;
				case 9:$('.f8').addClass('f8a');$('.zj8').addClass('zj8a');aud2.play();
				fnum++;break;
			}
		}
		
		
	})
	touch.on('.g1p1','swiperight',function(){
		if(bol){
			if(fnum>=10){
				fnum=10;
			}
			if(fnum<=1){
				fnum=1;
			}	
			switch(fnum){
				case 2:$('.f1').removeClass('f1a');$('.zj1').removeClass('zj1a');aud2.play();
				fnum--;break;
				case 3:$('.f2').removeClass('f2a');$('.zj2').removeClass('zj2a');aud2.play();
				fnum--;break;
				case 4:$('.f3').removeClass('f3a');$('.zj3').removeClass('zj3a');aud2.play();
				fnum--;break;
				case 5:$('.f4').removeClass('f4a');$('.zj4').removeClass('zj4a');aud2.play();
				fnum--;break;
				case 6:$('.f5').removeClass('f5a');$('.zj5').removeClass('zj5a');aud2.play();
				fnum--;break;
				case 7:$('.f6').removeClass('f6a');$('.zj6').removeClass('zj6a');aud2.play();
				fnum--;break;
				case 8:$('.f10').removeClass('f10a');$('.zj10').removeClass('zj10a');aud2.play();
				fnum--;break;
				case 9:$('.f7').removeClass('f7a');$('.zj7').removeClass('zj7a');aud2.play();
				fnum--;break;
				case 10:$('.f8').removeClass('f8a');$('.zj8').removeClass('zj8a');aud2.play();
				fnum--;break;
				
			}
		}	
	})

	
	//翻页结束-------------------------------------------------------------------------------------------------
	
	
})